<template>
  <!-- <div class="book-box">
    <div class="book-card" v-for="(item,index) in books" :key="index">
      <img :src="item.image" alt />
      <div class="book-point">
        <h1>{{item.title}}</h1>
        <h2>{{item.author}}</h2>
        <div class="book-rate">
          <span>{{item.rate}}分</span>
          <Rate theme="red" :value="item.rate"></Rate>
          <span class="span-nick">{{item.userInfo.nickName}}</span>
        </div>
      </div>
    </div>
  </div>-->
  <!-- <a :href="detailUrl"> -->
  <div class="book-box">
    <div class="book-card" @click="waiting">
      <img :src="book.image" alt @click.stop="preview" />
      <div class="book-point">
        <h1>{{book.title}}</h1>
        <h2>{{book.author}}</h2>
        <div class="book-rate">
          <span>{{book.rate}}分</span>
          <Rate theme="red" :value="book.rate"></Rate>
          <span class="span-nick">{{book.userInfo.nickName}}</span>
        </div>
      </div>
    </div>
  </div>
  <!-- </a> -->
</template>

<script>
import Rate from "@/components/Rate";
export default {
  components: {
    Rate
  },
  props: ["book"],
  computed: {
    detailUrl() {
      return "/pages/detail/main?id=" + this.book._id;
    }
  },
  methods: {
    waiting() {
      wx.showToast({
        title: "搭建中...",
        icon: 'none'
      });
      return false;
    },
    preview() {
      wx.previewImage({
        current: this.book.image,
        urls: [this.book.image]
      });
    }
  }
};
</script>

<style scoped>
.book-box {
  padding: 0 15px;
}
.book-card {
  display: flex;
  /* margin: 0 15px; */
  padding: 10px 0;
  border-bottom: 1px solid #f2f2f2;
}
.book-card > img {
  display: block;
  min-width: 80px;
  width: 80px;
  height: 100px;
  /* max-width: 100%; */
  /* max-height: 100%; */
  /* border-radius: 2px; */
}
.book-point {
  flex: 1;
  padding: 6px 0 0 15px;
}
.book-point h1 {
  width: 220px;
  font-weight: bold;
  font-size: 18px;
  line-height: 38px;
  white-space: nowrap; /*规定段落中的文本不进行换行*/
  overflow: hidden; /*内容会被修剪，并且其余内容是不可见的。*/
  text-overflow: ellipsis; /*显示省略号来代表被修剪的文本*/
}
.book-point h2 {
  width: 160px;
  font-size: 14px;
  color: #666666;
  margin-bottom: 8px;
  white-space: nowrap; /*规定段落中的文本不进行换行*/
  overflow: hidden; /*内容会被修剪，并且其余内容是不可见的。*/
  text-overflow: ellipsis; /*显示省略号来代表被修剪的文本*/
}
.book-point .book-rate span {
  font-size: 14px;
  color: #666666;
  margin-right: 10px;
}
.book-point .book-rate .span-nick {
  font-size: 10px;
  float: right;
  position: relative;
  top: 6px;
}
</style>
